import scala.collection.mutable.ArrayBuffer

/**
 * Created by Administrator on 2015/12/28 0028.
 */
object trait_test {
  def main(args: Array[String]) {
//      val bb=new bbb with ccc
    val q1=(new BasicQueue with  Incrementing with  Doubling)
    q1.put(2)
    println(q1.get())
    val q2=(new BasicQueue with  Doubling with  Incrementing)
    q2.put(2)
    println(q2.get())
  }
}


abstract  class IntQueue{def get():Int;def put(x:Int)}

class BasicQueue extends  IntQueue{
  private val buf=new ArrayBuffer[Int]
  override def get()=buf.remove(0)
  override def put(x: Int){buf+=x}
}

trait  Incrementing extends  IntQueue{
  abstract  override  def put(x:Int): Unit ={
    super.put(x+1)
  }
}

trait Doubling extends  IntQueue{
  abstract  override  def put(x:Int): Unit ={
    super.put(2*x)
  }
}

trait  ta{
  def log(msg:String)
  def dolog(msg:String){println(msg)}
}

trait tb{

}

class aaa extends  ta with  tb{
  def log(msg:String){print(msg)}
}

trait ccc extends eee{

}

class bbb{

}
class eee{

}